<?php
require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('goodsorder');

$adcode = isset($adcode) ? $adcode : ''; //地区代码
$jindu = isset($jindu) ? $jindu : '';


$sql = "SELECT f.*,t.dataname as typename,j.dataname as jinduname,u.nickname as nickname ,u.headimgurl as headimgurl,u.school as school,u.sheng as sheng,u.shi as shi,u.qu as qu,u.address as address,u.mobile as mobile,u.truename as truename FROM `#@__order` as f
		left join `#@__user`  as u on u.id=f.uid
		left join `#@__cascadedata`  as t on t.datavalue=f.apply_type  
		left join `#@__cascadedata`  as j on j.datavalue=f.jindu  
		WHERE t.datagroup='type'  AND j.datagroup='jindu'  AND   f.delstate=''  ";
		if(!empty($adcode)) $sql .= " AND f.adcode=$adcode  ";
		if(!empty($jindu)) $sql .= " AND f.jindu=$jindu  ";
	$dopage->GetPage($sql);
	$order_arr=array();
	$oder_info=array();
	while($row = $dosql->GetArray())
	{
		$order_arr[]=$row['latitude'].",".$row['longitude'];
	    $oder_info[]="<h2>".$row['school']."</h2><br/>".$row['truename'].$row['mobile']."<br/>".$row['sheng']."-".$row['shi']."-".$row['qu']."-".$row['address']."<br/>设备：".$row['typename']."<br/>进度：".$row['jinduname']."<br/><a href='javascript:;'  onClick=dongdanshow('".$row['id']."')>点击查看</a>";
	}

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>为多个Marker添加事件</title>
</head>
<style type="text/css">
*{
    margin:0px;
    padding:0px;
}
body, button, input, select, textarea {
    font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
}
#container{
	min-width:600px;
	min-height:767px;
}
</style>
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=RZHBZ-63Z3X-34B4Y-7D7YI-XNPZH-TBFAM"></script>
<script>
 //查询

function init() {
    var center = new qq.maps.LatLng(34.820568,113.513489);
    var map = new qq.maps.Map(document.getElementById("container"), {
        center: center,
        zoom: 7
    });
    var infoWin = new qq.maps.InfoWindow({
        map: map
    });

    var latlngs = [
	<?php 
		foreach($order_arr as $key=>$val){
			echo " new qq.maps.LatLng(".$val."),";
		}
	?>
    ];
	var oder_info=<?php echo  json_encode($oder_info);?>;
	var order_list = eval(oder_info);
	console.log(order_list);
    var anchor = new qq.maps.Point(6, 6),
        size = new qq.maps.Size(24, 24),
        origin = new qq.maps.Point(0, 0),
        icon = new qq.maps.MarkerImage('img/center.gif', size, origin, anchor);
    for(var i = 0;i < latlngs.length; i++) {
        (function(n){
            var marker = new qq.maps.Marker({
                position: latlngs[n],
                map: map,
				icon: icon,
            });
            qq.maps.event.addListener(marker, 'click', function() {
                infoWin.open();
                infoWin.setContent(order_list[n]);
                infoWin.setPosition(latlngs[n]);
            });
        })(i);
    }
}
</script>
<body onload="init();">
<div id="container"></div>
</body>
</html>


